package com.hmall.user.web;


import com.hmall.user.pojo.Address;
import com.hmall.user.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired(required = false)
    private IAddressService addressService;

    //根据用户id查询用户地址
    @GetMapping("/uid/{id}")
    public List<Address> findAddressByUid(@PathVariable Long id){
        System.out.println("id = " + id);
        return addressService.findAddressByUid(id);
    }

    //根据addressId查询地址
    @GetMapping("/{addressId}")
    public Address findAdsByAid(@PathVariable Long addressId){
        return addressService.findAdsByAid(addressId);
    }

}
